using Godot;

public partial class CDoSkillState : CState
{
    [Export] public bool mInit = false;

    public override void run(Node n, double delta)
    {
        if (n is NCharacter cha)
        {
            _init(cha);

            CSkill skill = cha.getSkill(cha.mData.mSkillTarget.mID);
            if (skill.isEnd(cha))
            {
                cha.mData.mState = new CPreSkillState();
                return;
            }

            if (skill.canDoHurt(cha))
            {
                skill.doHurt(cha);
            }

            cha.play(ANI_TYPE.ATTACK);
        }
    }

    void _init(NCharacter cha)
    {
        if (mInit)
            return;

        mInit = true;

        cha.CurSkill.resetAniEvent(cha);
    }
}